import {defineComponent, getCurrentInstance, ref} from "vue";
import {loginReuqest, shareRegisterReuqest} from "@/net/Api";
import {onLoad} from "@dcloudio/uni-app";
import { useAppStore } from '@/stores/pinia'
import { storeToRefs } from 'pinia'

// import {DICT_LIST} from "@/common/Constants";

export default defineComponent({
    setup() {
        const {proxy} = getCurrentInstance()
        const txt = ref("测试文字")
        const store = useAppStore()
        const {data } = storeToRefs(store)// data 是响应式的 ref

        onLoad(() => {
                store.setData({name:"测试数据"})

            // DICT_LIST
            let params = {
                mobile: "13071179037",
                password: "111111",
                userType: 1
            }
            loginReuqest(params).then((res) => {
                uni.setStorageSync('token', res.data.accessToken)

                proxy.$Toast(proxy, "测试Toast")
                setTimeout(() => {
                    getRequest()
                }, 500)
            }).catch((err) => {

            })
        })

        const getRequest = () => {
            shareRegisterReuqest(null).then((res) => {

            }).catch((err) => {

            })
        }

        return {
            txt,
            data,
        }
    }
})
